﻿using Dsl.Ped.Common.Converters;
using Dsl.Ped.Framework.Helpers;

namespace Dsl.Ped.Framework.Converters {

    /// <summary>
    /// Convert the input object to the string, which is localized against the dictionary
    /// </summary>
    public class ObjectToLocalizedStringConverter : AbstractObjectToLocalizedStringConverter 
    {
        /// <summary>
        /// Localize object against the dictionary based on its type
        /// </summary>
        /// <param name="value">Object to localize</param>
        /// <returns>Object localized against the dictionary</returns>
        public override string Localize(object value)
        {
            if (value == null) return string.Empty;

            if (value.GetType().IsEnum)
            {
                return EnumHelper.Localize(value);
            } 
            
            if (value.GetType() == typeof(string))
            {
                return StringHelper.Localize(value as string);
            }

            return value.ToString();
        }
    }
}
